<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>写日志</title>
		<link type="text/css" rel="stylesheet" href="../jquery-easyui-1.4.2/themes/default/easyui.css">
		<link type="text/css" rel="stylesheet" href="../jquery-easyui-1.4.2/themes/icon.css">
		<script type="text/javascript" src="../js/jquery-2.1.1.min.js"></script>
		
		<link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css" />
		<script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script>
		
		<script type="text/javascript" src="../jquery-easyui-1.4.2/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../jquery-easyui-1.4.2/locale/easyui-lang-zh_CN.js"></script>
		<script type="text/javascript" src="../js/dateFormat_CY.js"></script>
		<script type="text/javascript">
			//按条件组合搜索
			function searchLog(){
				var logType = $("#input_logType").combo('getValue');
    			var keyword = $("#input_keyword").val();
    			var fromDate = $("#input_fromDate").datebox('getValue');
    			var toDate = $("#input_toDate").datebox('getValue');
    			var deptId = $("#input_dempManager").combo('getValue');
				$('#dg').datagrid('load',
						{pageNo:1, pageSize:10,
						logType:logType,keyword:keyword,
						fromDate:fromDate,toDate:toDate,
						deptId:deptId
					});
			};
			function serAllLog(){
    			var logType = $("#input_logType").combo('setValue',-1);
    			var keyword = $("#input_keyword").val("");
    			var fromDate = $("#input_fromDate").datebox('setValue',"");
    			var toDate = $("#input_toDate").datebox('setValue',"");
    			var deptId = $("#input_dempManager").combo('setValue',-1);
    			searchLog();
    		};
			//加载组合条件查询的下拉数据
			$(function(){
				//加载分类的数据
				$.post("../log/loadLogType.do",function(data){
					$('#input_logType').combobox({  
						data:data,
						editable:false,
					    valueField:'typeId',    
					    textField:'logTypeName'   
					}); 
				},"json");
				//加载部门名称的数据
				$.post("../log/loadDepartmentName.do",function(data){
					$('#input_dempManager').combobox({  
						data:data,
						editable:false,
					    valueField:'deptId',    
					    textField:'deptName'   
					}); 
				},"json");
			});
			$(function(){
				//加载表格渲染数据
				$('#dg').datagrid({    
				    url:'../log/loadOtherCanSee.do?userId=<%=request.getParameter("userId")%>',
				    pagination:true,
				    rownumbers:true,
				    striped:true,
				    queryParams:{pageNo:1,pageSize:10,logType:-1,keyword:"",
				    	fromDate:"",toDate:"",
				    	deptId:-1},
				    frozenColumns:[[{field:"checkboxes",width:50,checkbox:true}]],
				    columns:[[   
						{field:'deptName',title:'部门',width:100,align:'center'},
						{field:'logId',title:'部门',width:100,align:'center',hidden:true},
				        {field:'logTitle',title:'标题',width:100,align:'center',
							formatter:function(logTitle,rows){
				        		return "<a href='../log/seeLog.do?logId="+rows.logId+"'>"+logTitle+"</a>";
				        }},    
				        {field:'typeName',title:'类别',width:100,align:'center'}, 
				        {field:'userName',title:'姓名',width:100,align:'center'},    
				        {field:'logDateTime',title:'日期',width:120,
				        	align:'center',formatter:formatDateBoxFull },
				        {field:'logContext',title:'内容',width:600,align:'center'}    
				    ]]
			    	/* toolbar:"#toolbar"  */
				   /*  toolbar: [{
						iconCls: 'icon-edit',
						text:'查看',
						handler: function(){
							var selections = $("#dg").datagrid("getSelections");
			    			if(selections.length ==0){
			    				$.messager.alert('错误','请选择要查看的日志');
			    				return ;
			    			}
			    			if(selections.length >1){
			    				$.messager.alert('错误','请选择一条需要查看的日志');
			    				return ;
			    			}
			    			$('#win').window('open');  // open a window 
			    			var userId = selections[0].userId;
			    			$.post("/loadUserById.action",{userId:userId},function(data){
			    				$("#form").form("load", data);
			    			},"json");
						}
					},'-',{
						iconCls: 'icon-help',
						handler: function(){alert('帮助按钮')}
					}] */

				});
				var page = $('#dg').datagrid('getPager');
				page.pagination({
					onSelectPage:function(pageNumber, pageSize){
						$('#dg').datagrid('load',{pageNo:pageNumber, pageSize:pageSize});
						page.pagination({
							pageNumber:pageNumber,
							pageSize:pageSize,
							logType:-1,
							keyword:"",
							fromDate:"",
							toDate:"",
							deptId:-1
						});
					}
				});
			});
		</script>
	</head>
	<body>
		<!--添加工具栏按键，增删编辑和组合查询-->
		<div id="toolbar" class="row" style="margin-top: 30px;">
			
			<div class="col-md-3 col-lg-offset-1" >
				<span>关键字:</span>
		  		<input id="input_keyword" style="border-radius: 5px;border-color: #9ACFEA;height: 30px;width: 200px;" type="text" placeholder="请输入内容的关键字" >
			</div>
			<div class="col-md-3" >
			  	<span>类别:</span>
				<select id="input_logType" class="easyui-combobox" name="input_logType" style="height: 30px;width: 200px;"></select>
			</div>
			<div class="col-md-3" >
			  	<span>部门主管:</span>
				<select id="input_dempManager" class="easyui-combobox" name="input_dempManager" style="height: 30px;width: 200px;"></select>
			</div>
			
		</div>
		<div class="row" style="margin-top: 20px;">
			<div class="col-md-3 col-lg-offset-1" >
				<span>&nbsp;&nbsp;日  期:</span>
		  		<input id="input_fromDate" type="text" style="height: 30px;width: 200px;" class="easyui-datebox">
			</div>
			<div class="col-md-3" >
		  		<span>&nbsp;&nbsp;&nbsp;至:</span>
		  		<input id="input_toDate" type="text" style="height: 30px;width: 200px;" class="easyui-datebox">
			</div>
			<div class="col-md-3" >
				<a id="btn" href="javascript:searchLog();" class="easyui-linkbutton" data-options="iconCls:'icon-search'">搜索</a> 
			    <a style="margin-left: 20px" href="javascript:serAllLog();" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查看全部</a>
			</div>
			
			
		</div>
		<table id="dg"></table>
		
		
		
		
	</body>
</html>